<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Page
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: Menus.php 2010-08-31 16:05 idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Page
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 */

class Fan_Plugin_Menus
{
  public function onMenuInitialize_UserBecomeFan($row)
  {
    $viewer = Engine_Api::_()->user()->getViewer();
    $subject = Engine_Api::_()->core()->getSubject();
    // @todo move to authorization
     
/* This Code is for :
 *      if a person already in his profile :: Person will not get Become a fan option for him-self
 */
    
    // Not logged in
    if( !$viewer->getIdentity() || $viewer->getGuid(false) === $subject->getGuid(false) ) {
      return false;
    }
    if($viewer->isSelf($subject)){
        return false;
    }
    $isFan = Engine_Api::_()->fan()->isFan($subject);
    if($isFan instanceof Fan_Model_Fan) {
     return array(
                'label' => 'Undo Fan',
                'icon' => 'application/modules/User/externals/images/friends/remove.png',
                'route' => 'fan_general',
                'params' => array(
                    'id' => $isFan->getIdentity(),
                    'action' => 'remove',
                    'format' => 'smoothbox'
                ),
                'class' => 'smoothbox',
            );
     
    }
 
else {    
/* CODE ENDS HERE **/
    
    return array(
      'label' => 'Become A Fan',
      'icon' => 'application/modules/Icustom/externals/images/become_a_fan.png',
      'route' => 'fan_general',
      'params' => array(
      'id' => $subject->getIdentity(),
      'format' => 'smoothbox'
      ),
      'class' => 'smoothbox',
       
    );
}
    
  }
    
  
}